package TOP101;

/**
 * @Question BM30
 * @Date 2022/11/11 11:44
 * @Solution
 */
public class BM30 {
    TreeNode pre=null;
    TreeNode head=null;
    public TreeNode Convert(TreeNode pRootOfTree) {
        if(pRootOfTree==null) {
            return null;
        }
        inorder(pRootOfTree);
        return head;
    }
    public void inorder(TreeNode root) {
        if(root==null) return;
        inorder(root.left);
        if(pre==null) {
            head=root;
        }
        if(pre!=null) {
            root.left=pre;
            pre.right=root;
        }
        pre=root;
        inorder(root.right);
    }
}
